package game.waypoint;
import java.io.Serializable;
import java.util.Vector;

import tools.Floatmath;
import tools.Help;
import tools.Point;
public class Path implements Serializable {
	private Vector<Point> points;
	private int currentaim;
	private float length;
	public Path(Vector<Point> pts) {
		this.points = pts;
		currentaim = 0;
		length = 0;
		for (int i = 0; i < points.size() - 1; i++) {
			length += pts.get(i).squaredDistance(pts.get(i + 1));
		}
		length = Floatmath.sqrt(length);
	}
	public float length() {
		return length;
	}
	public int pointsLeft() {
		return points.size() - currentaim;
	}
	public Point getNextPoint() {
		if (points.size() > 0) {
			Point r = points.get(currentaim);
			currentaim = Math.min(points.size() - 1, currentaim + 1);
			return r;
		}
		Help.p("hey there is no point in this path!!!");
		return null;
	}
	public Point getCurrentAim() {
		if (currentaim < points.size())
			return points.get(currentaim);
		Help.p("hey there is no more point in this path!!!" + points.size());
		return null;
	}
	public Vector<Point> getPoints() {
		return this.points;
	}
	public boolean atLastPoint() {
		return currentaim == points.size() - 1;
	}
}
